package br.com.iplant.teste.dao;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import br.com.iplant.dao.SafraDAO;
import br.com.iplant.vo.Safra;

public class SafraDAOTest {
	SafraDAO safraDAO = new SafraDAO();

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@AfterClass
	public static void tearDownAfterClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	/**
	 * Salva uma safra e espera que retorne a safra com a chave
	 */
	@Test
	public void testSalvar() {

		assertTrue(safraDAO.salvar(new Safra(2012, 2013, 0001)).getSafra_id()!=0);

	}

	@Test
	public void testBuscarUM() {
		assertNotNull(safraDAO.buscarUM(safraDAO.salvar(new Safra(2012, 2013, 0001))));
	}

	@Test
	public void testGetTodasAsSafras() {
		assertTrue(safraDAO.getTodasAsSafras().size()>0);
	}

	@Test
	public void getSafraPelosAnosESequencia() {
		assertNotNull(safraDAO.getSafraPelosAnosESequencia(safraDAO.salvar(new Safra(2012, 2013, 0001))));
	}

}
